﻿Imports System.Windows.Forms
Imports System.Text.RegularExpressions

Public Class FormCalc

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Actualiser()
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Actualiser()
    End Sub

    Public Sub Actualiser()
        Dim Result As String
        Try
            Dim oExpressionTree As New ExpressionTree(Me.TextBox1.Text)
            Result = oExpressionTree.Evaluate().ToString
        Catch ex As Exception
            Result = "Expression erronée : " & ex.Message
        End Try
        Me.LabelResult.Text = Result
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        FormBrowser.WebBrowser1.DocumentText = My.Resources.CalcHelp
        FormBrowser.Show()
    End Sub
End Class
